package org.dearsor.elective.service;

import java.io.Serializable;

import org.dearsor.elective.model.Person;
import org.dearsor.elective.repository.GenericRepositoryImpl;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository
@Transactional(readOnly = true)
public class PersonMgrImpl extends GenericRepositoryImpl<Person> implements PersonMgr {

	public Person findPersonByUsernameAndPassword(String uid, String pwd)
			throws DataAccessException {
		return (Person) getEntityManager()
				.createQuery(
						"select u from Person u where u.name = :uid and u.password = :pwd")
				.setParameter("uid", uid).setParameter("pwd", pwd)
				.getSingleResult();
	}

	public Person find(long id)
			throws DataAccessException {
		// TODO Auto-generated method stub
		return find(Person.class, id);
	}



}
